package com.itwlj.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface GoodsSpecLinksMapper {

    /**
     * 新增商品和规格关联信息
     *
     * @param goodsId
     * @param specId
     */
    @Insert("insert into goods_spec_links(goods_id, spec_id) values (#{goodsId},#{specId})")
    void insert(Long goodsId, Long specId);

    /**
     * 根据商品id获取关联的规格id
     *
     * @param goodsId
     * @return
     */
    @Select("select spec_id from goods_spec_links where goods_id = #{goodsId}")
    List<Long> getSpecIds(Long goodsId);

    /**
     * 根据商品id删除关联信息
     *
     * @param goodsIds
     */
    void deleteByGoodsIds(List<Long> goodsIds);
}
